#ifndef _ADC_H_
#define _ADC_H_


//#define ADC_ERR_CALIBRATION     1   
//#define ADC_ERR_BUSY            2   /* The ADC is busy */
#define ADC_ERR_ARGS            1   /* The arguments is wrong */

#define ADC_ERR_CMD             2

/* ADC contrl bit */
#define  ADC_WT_INT_EN     0x00800000
#define  ADC_LV_INT_EN     0x00400000
#define  ADC_INT_EN        0x00200000
#define  ADC_EN            0x00020000
#define  ADC_RST           0x00010000
#define  ADC_CONV          0x00002000
#define  ADC_TSC_XY        0x00000100
#define  ADC_PU_EN         0x00000008
#define  ADC_LV_EN         0x00000004

/* ADC status */
#define  ADC_WT_INT        0x00100000
#define  ADC_LV_INT        0x00080000
#define  ADC_INT           0x00040000
#define  ADC_UD            0x00000001

typedef INT32 (*ADC_CALLBACK)(UINT32 status, UINT32 userData);

typedef enum 
{  
   NORMAL   = 0, 
   SEMIAUTO = 1, 
   AUTO     = 2,
   TRIG     = 3
}ADC_TSC_MODE;

typedef enum 
{  
   AIN0  = 0, 
   AIN1  = 1, 
   AIN2  = 2,
   AIN3  = 3,
   AIN4  = 4,
   AIN5  = 5,
   AIN6  = 6,
   AIN7  = 7
}ADC_CHAN;


//typedef enum 
//{  
#define   WIRE4   0 
#define   WIRE5   1 
#define   WIRE8   2
//}ADC_TSC_TYPE;

//typedef enum 
//{  
#define   SW1   0 
#define   SW2   1 
#define   SW3   2
#define   SW4   3
//}LV_SW_CON;

typedef enum
{
   START_CONV,
   WT_INT_ON,
   WT_INT_OFF,
   LV_INT_ON,
   LV_INT_OFF,
   ADC_INT_ON,
   ADC_INT_OFF,
//   TSC_MODE_SW,
//   ADC_CHAN_SW,
   ADC_TSC_XY_CTL,
   ADC_PU_ON,
   TSC_TYPE_SW,
   WT_DELAY,
   ADC_DELAY,
   LV_ON,
   LV_SW,
   CLEAR_INT_FLAG
       
}ADC_CMD;

INT adcInit(VOID);
INT adcOpen(ADC_TSC_MODE mode, INT32 clockDiv, ADC_CHAN channel);
INT adcClose(VOID);
INT adcRead(INT16 *bufX, INT16 *bufY, INT32 dataCnt);
INT adcIoctl(ADC_CMD cmd, INT32 arg1, INT32 arg2);
INT adcChangeTscMode(ADC_TSC_MODE mode);
INT adcChangeChannel(ADC_CHAN channel);
#endif